<script language="javascript" type="text/javascript">
function delete_entity(id)
{
  var check = confirm('Are you sure?');
  if (check == true) {
      document.entity_delete_form.entity.value = id;
      document.entity_delete_form.action = "/<%=@project_name%>/meta_entities/" + id + "/delete"
      document.entity_delete_form.submit();
      return true;
  }
  else {
      return false;
  }
}
</script>

<div class="col-sm-2">
  <%= erb :'/entities/_search', :layout => false %>
</div>
<div class="col-sm-10">
    <a href="/<%=@project_name%>/entities?search_string=<%=@search_string%>&correlate=on&page=<%=@page-1%>&<%=@entity_types.map{|x| "entity_types[]=#{x}" }.join('&') if @entity_types %>">previous</a>
    <a href="/<%=@project_name%>/entities?search_string=<%=@search_string%>&correlate=on&page=<%=@page+1%>&<%=@entity_types.map{|x| "entity_types[]=#{x}" }.join('&') if @entity_types %>">next</a>
    <%= "Page: #{@page}" %> / <%= "Viewing Results: #{@count * (@page-1)} .. #{@count * @page-1}" %>

  <script type="text/javascript" src="/js/sorttable.js"></script>
  <style>
  /* Sortable tables */
  table.sortable {
    width: 100%;
    border: 0;
    table-layout:fixed;
    word-wrap:break-word;
    border-collapse:collapse;
  }

  table.sortable thead {
      background-color:#eee;
      color:#666666;
      font-weight: bold;
      cursor: default;
  }
  </style>
  <p></p>
  <table class="sortable" border="1" width=100%>
    <colgroup>
      <col style="width:60%">
      <col style="width:40%">
    </colgroup>
    <tbody>
      <tr><th>name</th><th>details</th></tr>
      <% @alias_groups.each do |group| %>
        <% next if group.entities.empty? %>
        <tr>
          <td>
            <ul>
          <% group.entities.each do |e| %>
            <%
               # skip hidden unless we allow it
               unless @include_hidden
                next if e.hidden
               end
            %>
                <li>[<a href="/<%=@project_name%>/entities/<%=e.id%>"> <%= h e %> </a>]</li>
          <% end %>
              </ul>
            </td>
            <td>
              <ul>
          <% group.entities.each do |e| %>
            <%
              # skip hidden unless we allow it
              unless @include_hidden
               next if e.hidden
              end
            %>
              <li><a href="/<%=@project_name%>/entities/<%=e.id%>"> <%= h e.detail_string %> </a></li>
        <% end %>
            </ul>
          </td>
        </tr>
      <% end %>

    </tbody>
  </table>
  <a href="/<%=@project_name%>/entities?search_string=<%=@search_string%>&correlate=on&page=<%=@page-1%>&<%=@entity_types.map{|x| "entity_types[]=#{x}" }.join("&") if @entity_types %>">previous</a>
  <a href="/<%=@project_name%>/entities?search_string=<%=@search_string%>&correlate=on&page=<%=@page+1%>&<%=@entity_types.map{|x| "entity_types[]=#{x}" }.join("&") if @entity_types %>">next</a>
<form name="entity_delete_form" method="get"><input type="hidden" id="entity" name="entity"/></form>
</div>
